##=== TEST.nightly.report - Report description for nightly -----*- perl -*-===##
#
# This file defines a report to be generated for the nightly tests.
#
##===----------------------------------------------------------------------===##

# Sort by program name
$SortCol = 0;
$TrimRepeatedPrefix = 1;

my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";

# FormatTime - Convert a time from 1m23.45 into 83.45
sub FormatTime {
  my $Time = shift;
  if ($Time =~ m/([0-9]+)[m:]([0-9.]+)/) {
    return sprintf("%7.4f", $1*60.0+$2);
  }

  return sprintf("%7.4f", $Time);
}

sub GCCLLCRatio {
  my ($Cols, $Col) = @_;
  my $GCC = $Cols->[$Col-7];
  my $LLC = $Cols->[$Col-5];
  return "n/a" if ($GCC eq "*" or $LLC eq "*");
  return sprintf("%3.2f", $GCC/$LLC) if ($GCC >= 0.1 and $LLC >= 0.1);
  return "-";
}

sub GCCLLC_BETARatio {
  my ($Cols, $Col) = @_;
  my $GCC = $Cols->[$Col-8];
  my $LLC_BETA = $Cols->[$Col-5];
  return "n/a" if ($GCC eq "*" or $LLC_BETA eq "*");
  return sprintf("%3.2f", $GCC/$LLC_BETA) if ($GCC >= 0.1 and $LLC_BETA >= 0.1);
  return "-";
}

sub LLCLLC_BETARatio {   # LLC/LLC-BETA
  my ($Cols, $Col) = @_;
  my $LLC = $Cols->[$Col-7];
  my $LLC_BETA = $Cols->[$Col-6];
  return "n/a" if ($LLC eq "*" or $LLC_BETA eq "*");
  return sprintf("%3.2f", $LLC/$LLC_BETA) if ($LLC >= 0.1 and $LLC_BETA >= 0.1);
  return "-";
}

sub INSTNATRatio {   # INST/NAT
  my ($Cols, $Col) = @_;
  my $INST = $Cols->[$Col-3];
  my $NAT = $Cols->[$Col-5];
  return "n/a" if ($INST eq "*" or $NAT eq "*");
  return sprintf("%3.4f", $INST/$NAT) if ($INST >= 0.001 and $NAT >= 0.001);
  return "-";
}

sub INSTLLCRatio {   # INST/LLC
  my ($Cols, $Col) = @_;
  my $INST = $Cols->[$Col-2];
  my $LLC = $Cols->[$Col-3];
  return "n/a" if ($LLC eq "*" or $INST eq "*");
  return sprintf("%3.4f", $INST/$LLC) if ($INST >= 0.001 and $LLC >= 0.001);
  return "-";
}

# highlight the RATIO columns with green/red.
$HilightColumns{8} = 1;
$HilightColumns{9} = 1;

# These are the columns for the report.  The first entry is the header for the
# column, the second is the regex to use to match the value.  Empty list create
# separators, and closures may be put in for custom processing.
(
# Name
 ["Program"  , '\'([^\']+)\' Program'],
 [],
# Instrumentation
 ["NumInstrumentedLoops"    , '([0-9]+).*Number of Instrumented Loops'],
 ["NumIntervalLoops"        , '([0-9]+).*Number of Interval Loops'],
 ["NumEqualityLoops"        , '([0-9]+).*Number of Equality Loops'], 
 ["NumOtherLoops"           , '([0-9]+).*Number of Other Loops'],
 [],
 ["NumUnknownConditionsIL"  , '([0-9]+).*Number of Interval Loops With Unknown TripCount'],
 ["NumUnknownConditionsEL"  , '([0-9]+).*Number of Equality Loops With Unknown TripCount'], 
 ["NumUnknownConditionsOL"  , '([0-9]+).*Number of Other Loops With Unknown TripCount'],
 [], 
# Accuracy
 ["TC Accuracy - IL"        , 'TripCount Accuracy \(Interval Loops\)\s*([.0-9]+)'],
 ["TC Accuracy - EL"        , 'TripCount Accuracy \(Equality Loops\)\s*([.0-9]+)'],
 ["TC Accuracy - OL"        , 'TripCount Accuracy \(Other Loops\)\s*([.0-9]+)'], 
 ["TC Accuracy - All"       , 'TripCount Accuracy \(All Loops\)\s*([.0-9]+)'],
 [],
# Times
 ["NAT"                     , 'TEST-RESULT-nat-time: user\s*([.0-9m:]+)', \&FormatTime],
 ["LLC"                     , 'TEST-RESULT-llc-time: user\s*([.0-9m:]+)', \&FormatTime],
 ["INST"                    , 'TEST-RESULT-instr-time: user\s*([.0-9m:]+)',\&FormatTime],
 [],
 ["INST/LLC"  , \&INSTLLCRatio],
 ["INST/NAT"  , \&INSTNATRatio],
);
